{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<!--NAVIGATION-->\n",
    "< [更多IPython资源](01.08-More-IPython-Resources.ipynb) | [目录](Index.ipynb) | [理解Python中的数据类型](02.01-Understanding-Data-Types.ipynb) >\n",
    "\n",
    "<a href=\"https://colab.research.google.com/github/wangyingsm/Python-Data-Science-Handbook/blob/master/notebooks/02.00-Introduction-to-NumPy.ipynb\"><img align=\"left\" src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open in Colab\" title=\"Open and Execute in Google Colaboratory\"></a>\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Introduction to NumPy\n",
    "\n",
    "# NumPy 介绍"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "> This chapter, along with chapter 3, outlines techniques for effectively loading, storing, and manipulating in-memory data in Python.\n",
    "The topic is very broad: datasets can come from a wide range of sources and a wide range of formats, including be collections of documents, collections of images, collections of sound clips, collections of numerical measurements, or nearly anything else.\n",
    "Despite this apparent heterogeneity, it will help us to think of all data fundamentally as arrays of numbers.\n",
    "\n",
    "下面我们将开启新的一章，本章连同第三章一起，会介绍和讨论高效的装载，存储和处理Python中内存数据的技巧。这个主题非常广泛：数据集可能来自非常不同的来源和非常不同的格式，包括文档的集合，图像的集合，声音片段的集合，数值测量的集合，甚至其他任何东西的集合。尽管数据集有着超出想象的异质性，我们还是可以将所有的数据抽象成为数值组成的数组。\n",
    "\n",
    "> For example, images–particularly digital images–can be thought of as simply two-dimensional arrays of numbers representing pixel brightness across the area.\n",
    "Sound clips can be thought of as one-dimensional arrays of intensity versus time.\n",
    "Text can be converted in various ways into numerical representations, perhaps binary digits representing the frequency of certain words or pairs of words.\n",
    "No matter what the data are, the first step in making it analyzable will be to transform them into arrays of numbers.\n",
    "(We will discuss some specific examples of this process later in [Feature Engineering](05.04-Feature-Engineering.ipynb))\n",
    "\n",
    "例如图像，这里我们特指数字图像，可以被认为是简单的二维数组，包含着代表这区域内每个像素亮度的数值。声音片段可以被认为是一维的数组，包含着时间范围内声音强度的数值。文本可以使用各种方法转换成为数值方式表示，比方说使用二进制数字表示某个单词或短语的出现频率。无论数据是哪种类型，我们对它们进行处理的时候，第一步总是设计将它们转换为数值。（参见[特征工程](05.04-Feature-Engineering.ipynb)）\n",
    "\n",
    "> For this reason, efficient storage and manipulation of numerical arrays is absolutely fundamental to the process of doing data science.\n",
    "We'll now take a look at the specialized tools that Python has for handling such numerical arrays: the NumPy package, and the Pandas package (discussed in Chapter 3).\n",
    "\n",
    "因此，有效的存储和处理数值数组对于数据科学来说是最根本的能力。我们接下来会讨论Python中具备这样强大功能的特殊工具：NumPy和Pandas（将在第三章讨论）。\n",
    "\n",
    "> This chapter will cover NumPy in detail. NumPy (short for *Numerical Python*) provides an efficient interface to store and operate on dense data buffers.\n",
    "In some ways, NumPy arrays are like Python's built-in ``list`` type, but NumPy arrays provide much more efficient storage and data operations as the arrays grow larger in size.\n",
    "NumPy arrays form the core of nearly the entire ecosystem of data science tools in Python, so time spent learning to use effectively will be valuable no matter what aspect of data science interests you.\n",
    "\n",
    "本章会详细介绍NumPy（*Numerical Python* 数值Python的缩写），它提供了强大的接口供我们存储和操作非稀疏数据集合。在某些情况下，NumPy的数组表现得就像Python內建的`列表`，但是NumPy数组在存储和操作大量数据集合的时候提供了有效得多的功能和性能。NumPy数组是Python的数据科学领域工具链的核心，很多其他的工具都是在它的基础上构建的，因此无论你感兴趣的是数据科学的哪个领域，NumPy都值得你花时间进行钻研。\n",
    "\n",
    "> If you followed the advice outlined in the Preface and installed the Anaconda stack, you already have NumPy installed and ready to go.\n",
    "If you're more the do-it-yourself type, you can go to http://www.numpy.org/ and follow the installation instructions found there.\n",
    "Once you do, you can import NumPy and double-check the version:\n",
    "\n",
    "如果你遵从这本书序言的内容安装的Anaconda，那么NumPy已经自动安装好了，你可以继续往下阅读。如果你喜欢DIY，你可以到[NumPy官网](http://www.numpy.org/)，然后按照提示自行安装。当你完成之后，你就可以在你的脚本中载入NumPy模块了，然后输出NumPy的版本号验证安装结果："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'1.16.4'"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy\n",
    "numpy.__version__"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "> For the pieces of the package discussed here, I'd recommend NumPy version 1.8 or later.\n",
    "By convention, you'll find that most people in the SciPy/PyData world will import NumPy using ``np`` as an alias:\n",
    "\n",
    "对于本书中的例子来说，作者推荐安装NumPy 1.8或以上版本。习惯上，大多数人都会使用`np`作为别名来载入NumPy模块："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "> Throughout this chapter, and indeed the rest of the book, you'll find that this is the way we will import and use NumPy.\n",
    "\n",
    "本章以及本书后续内容，这都是我们载入NumPy模块的标准方式。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Reminder about Built In Documentation\n",
    "\n",
    "## 內建帮助和文档\n",
    "\n",
    "> As you read through this chapter, don't forget that IPython gives you the ability to quickly explore the contents of a package (by using the tab-completion feature), as well as the documentation of various functions (using the ``?`` character – Refer back to [Help and Documentation in IPython](01.01-Help-And-Documentation.ipynb)).\n",
    "\n",
    "在你阅读本章的过程中，请不要忘记了IPython提供的內建帮助工具`?`以及使用制表符自动补全的功能。（参见：[IPython帮助和文档](01.01-Help-And-Documentation.ipynb)。\n",
    "\n",
    "> For example, to display all the contents of the numpy namespace, you can type this:\n",
    "\n",
    "例如，要查看numpy模块中的所有内容（属性和方法），你可以输入：\n",
    "\n",
    "```python\n",
    "In [3]: np.<TAB>\n",
    "```\n",
    "\n",
    "> And to display NumPy's built-in documentation, you can use this:\n",
    "\n",
    "如果想查看numpy的內建文档，你可以输入：\n",
    "\n",
    "```python\n",
    "In [4]: np?\n",
    "```\n",
    "\n",
    "> More detailed documentation, along with tutorials and other resources, can be found at http://www.numpy.org.\n",
    "\n",
    "需要更加详尽的文档、教程或其他资源，你可以访问[NumPy官网](http://www.numpy.org)。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<!--NAVIGATION-->\n",
    "< [更多IPython资源](01.08-More-IPython-Resources.ipynb) | [目录](Index.ipynb) | [理解Python中的数据类型](02.01-Understanding-Data-Types.ipynb) >\n",
    "\n",
    "<a href=\"https://colab.research.google.com/github/wangyingsm/Python-Data-Science-Handbook/blob/master/notebooks/02.00-Introduction-to-NumPy.ipynb\"><img align=\"left\" src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open in Colab\" title=\"Open and Execute in Google Colaboratory\"></a>\n"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
